function ajax({ type = 'GET', url = '', params = {} }) {
    return new Promise((resolve, reject) => {
        const xml = new XMLHttpRequest()
        let concatUrl = '';

        Object.keys(params).forEach((item, index) => {
            concatUrl += item + '=' + params[item] + '&';
        })
        concatUrl = concatUrl.substr(0, concatUrl.length - 1);

        if (concatUrl && type == 'GET') {
            url += '?' + concatUrl;
        }
        xml.open(type, url);
        if (type == 'POST') {
            xml.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8");
            xml.send(concatUrl)
        } else {
            xml.send(null)
        }
        xml.onreadystatechange = function() {
            if (xml.readyState == 4) {
                if (xml.status == 200) {
                    console.log(xml.responseText);

                    resolve(JSON.parse(xml.responseText))
                } else {
                    reject('err');
                }
            }
        }
    })
}